package com.googlecode.loframework.view.buttons
{
	import com.googlecode.loframework.view.IComponent;
	
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	import mx.controls.Button;
	
	import org.puremvc.as3.patterns.mediator.Mediator;

	public class ButtonMediator extends Mediator
	{
		private static var _count:int;
		private var _name:String;
		
		public function ButtonMediator(mediatorName:String, viewComponent:IComponent)
		{
			mediatorName += String(_count);
			
			super(mediatorName, viewComponent);
			
			_name = mediatorName;
			
			_count ++;
		}
		
		override public function onRegister():void
		{
			viewRef.addEventListener(MouseEvent.CLICK, onButtonClick);
		}
		
		override public function onRemove():void
		{
			viewRef.removeEventListener(MouseEvent.CLICK, onButtonClick);
		}
		protected function onButtonClick(evt:Event):void
		{
			//
		}
		
		protected function get viewRef():Button
		{
			return viewComponent as Button;
		}
		
		public function get name():String
		{
			return _name;
		}
	}
}